hackerrank time complexity Primality problem solution